package org.springcloud.plugin.common.entity;

import java.io.Serializable;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * author: yanggld
 * date: 2019/12/22 11:48
 * version: 1.0
 * description: StrategyCustomizationEntity
 */
public class StrategyCustomizationEntity implements Serializable {

    private List<StrategyConditionEntity> strategyConditionEntityList;
    private List<StrategyRouteEntity> strategyRouteEntityList;

    public List<StrategyConditionEntity> getStrategyConditionEntityList() {
        return strategyConditionEntityList;
    }

    public void setStrategyConditionEntityList(List<StrategyConditionEntity> strategyConditionEntityList) {
        this.strategyConditionEntityList = strategyConditionEntityList;
    }

    public List<StrategyRouteEntity> getStrategyRouteEntityList() {
        return strategyRouteEntityList;
    }

    public void setStrategyRouteEntityList(List<StrategyRouteEntity> strategyRouteEntityList) {
        this.strategyRouteEntityList = strategyRouteEntityList;

        // Header参数越多，越排在前面
        Collections.sort(this.strategyConditionEntityList, new Comparator<StrategyConditionEntity>() {
            @Override
            public int compare(StrategyConditionEntity object1, StrategyConditionEntity object2) {
                Integer count1 = object1.getHeaderMap().size();
                Integer count2 = object2.getHeaderMap().size();

                return count2.compareTo(count1);
            }
        });
    }
}
